import React, {Component} from 'react';
import {Text, View,} from 'react-native';


import {positiontwoStyle as styles} from '../../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';
import sal from '../../../../util/sal';

let Dimensions = require('Dimensions');
let width = Dimensions.get('window').width;          //获取屏幕宽度

export default class Postwo extends Component {
    // 初始化模拟数据
    constructor(props) {            //构造器只执行一次
        super(props);
    };

    render() {
        if (this.props.xzPostion.company === undefined) {
            return (
                <View style={[styles.postwotop, {width: width * 1}]}>

                    <View style={styles.postwotext}>
                        <Text style={styles.postwobold}></Text>
                        <Text style={styles.postwomoney}></Text>
                    </View>

                    <View style={styles.postwotext}>
                        <View style={styles.postwonormal}>
                            <Icon
                                name={'md-pin'}
                                size={16}
                                color={'#3d9ccc'} style={styles.postopicon2}/>
                            <Text style={styles.small}></Text>
                        </View>

                        <View style={styles.postwonormal}>
                            <Icon
                                name={'md-clipboard'}
                                size={16}
                                color={'#3d9ccc'} style={styles.postopicon2}/>
                            <Text style={styles.small}>年经验</Text>
                        </View>

                        <View style={styles.postwonormal}>
                            <Icon
                                name={'md-school'}
                                size={16}
                                color={'#3d9ccc'} style={styles.postopicon2}/>
                            <Text style={styles.small}></Text>
                        </View>

                    </View>

                    <View style={styles.postwotext}>
                        <Text style={styles.small2}>职位福利：</Text>
                    </View>

                    <View style={styles.posline}>
                    </View>
                </View>
            )
        } else {
            return (
                <View style={[styles.postwotop, {width: width * 1}]}>

                    <View style={styles.postwotext}>
                        <Text style={styles.postwobold}>{this.props.xzPostion.postionName}</Text>
                        <Text
                            style={styles.postwomoney}>{sal(this.props.xzPostion.postionMm, this.props.xzPostion.postionYm)}</Text>
                    </View>

                    <View style={styles.postwotext}>
                        <View style={styles.postwonormal}>
                            <Icon
                                name={'md-pin'}
                                size={16}
                                color={'#3d9ccc'} style={styles.postopicon2}/>
                            <Text style={styles.small}>{this.props.xzPostion.postionSpace}</Text>
                        </View>

                        <View style={styles.postwonormal}>
                            <Icon
                                name={'md-clipboard'}
                                size={16}
                                color={'#3d9ccc'} style={styles.postopicon2}/>
                            <Text style={styles.small}>{this.props.xzPostion.postionExp}年经验</Text>
                        </View>

                        <View style={styles.postwonormal}>
                            <Icon
                                name={'md-school'}
                                size={16}
                                color={'#3d9ccc'} style={styles.postopicon2}/>
                            <Text style={styles.small}>{this.props.xzPostion.postionEducation}</Text>
                        </View>

                    </View>

                    <View style={styles.postwotext}>
                        <Text
                            style={styles.small2}>职位福利：{this.welfareName(this.props.xzPostion.company.welfares, 3)}</Text>
                    </View>

                    <View style={styles.posline}>
                    </View>
                </View>

            )
        }
    }

    welfareName(List, sl) {
        var data = {
            cont: List
        }
        var arr = "";
        var s = sl;
        var length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (var i = 0; i < s; i++) {
            arr += data.cont[i].welfareName + ",";
        }
        if (arr.endsWith(',')) {
            arr = arr.substr(0, arr.length - 1);
        }
        return arr;
    }

}
